﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.EventSystems;

/// <summary>
/// 卷轴拖动效果
/// </summary>
public class ScrollEffect : MonoBehaviour
{
    public float speed=0.2f;
    public RectTransform drayScroll;
    public RectTransform rightScroll;
    public Vector2 targetV2 ;

    private Vector2 startV2 ;
    private float step;
    void Start()
    {
        startV2 = drayScroll.rect.size;
    }
    void Update()
    {
        step += Time.deltaTime * speed;
        drayScroll.sizeDelta = Vector2.Lerp(startV2, targetV2, step);
        var pos = drayScroll.anchoredPosition;
        pos.x += drayScroll.sizeDelta.x / 2 + 10;
        rightScroll.anchoredPosition = pos;
    }

}
